package lhy.utils;

import org.apache.commons.lang3.RandomStringUtils;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Locale;
import java.util.SplittableRandom;

public class IdUtils {
    static SplittableRandom random = new SplittableRandom();
    public static String generateIdWithDate(){
        return generateIdWithDate(LocalDate.now());
    }
    public static String generateIdWithDate(LocalDate date){
        int nextInt = random.nextInt(100000, 999999);
        String yyyyMMdd = DateTimeFormatter.ofPattern("yyyyMMdd", Locale.ENGLISH).format(date);
        return yyyyMMdd+nextInt;
    }
    public static String generateModel(){
        StringBuilder model=new StringBuilder();
        String s = RandomStringUtils.randomAlphabetic(random.nextInt(2,7)).toUpperCase(Locale.ROOT);
        model.append(s);
        model.append(RandomStringUtils.randomNumeric(random.nextInt(3,15)));
        return model.toString();
    }
}
